#include <iostream>
#include "BinaryTree.h"

// 100.00 %
class Solution
{
  public:
	bool isSameTree(TreeNode *p, TreeNode *q)
	{
		if (!p && !q)
			return true;
		else if (p && q)
			return p->val == q->val && isSameTree(p->left, q->left) && isSameTree(p->right, q->right);
		return false;
	}
};

using namespace std;
int main()
{
	int arr1[] = {1, 2, 0, 0, 0};
	int n1 = sizeof(arr1) / sizeof(arr1[0]);
	int arr2[] = {1, 0, 2, 0, 0};
	int n2 = sizeof(arr2) / sizeof(arr2[0]);
	TreeNode *tree1 = createBinaryTree(arr1, n1);
	TreeNode *tree2 = createBinaryTree(arr2, n2);
	preorderPrint(tree1);
	cout << endl;
	preorderPrint(tree2);
	cout << endl;
	cout << Solution().isSameTree(tree1, tree2) << endl;
	return 0;
}
